import cv2
import numpy as np
import base64
def cv2_base64(image_np):
    image = cv2.imencode('.jpg',image_np)[1]
    image_code = str(base64.b64encode(image))[2:-1]
    return image_code



def base64_cv2(base64_code):
    img_data = base64.b64decode(base64_code)
    img_array = np.frombuffer(img_data, np.uint8)
    img = cv2.imdecode(img_array, cv2.COLOR_RGB2BGR)
    return img


# __main__

img = cv2.imread('dataset/testdata/aobama.jpg')

print(type(cv2_base64(img)))

img1 = base64_cv2(cv2_base64(img))

cv2.imwrite('ttt12.jpg', img1)